const toast = ({ title = "数据加载中...", icon = "none", duration = 2000, mask = true } = {}) => {
  wx.showToast({
      title,
      icon,
      duration,
      mask
  })
}

// 想要生效，需要让这个文件执行一次。
wx.toast = toast

const modal = (options = {}) => {
  return new Promise((resolve) => {
      const defaultOpts = {
          title: "提示",
          content: "您确定执行该操作吗？",
          confirmColor: "#F3514F"
      }
      const opts = Object.assign({}, defaultOpts, options)
      wx.showModal({
          ...opts,
          complete({ confirm, cancel }) {
              confirm && resolve(true)
              cancel && resolve(false)
          }
      })
  })
}

// 想要生效，需要让这个文件执行一次。
wx.modal = modal

export { toast, modal }
